<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 边界 符 ^ $

        var sg = /abc/;

        //  正则表达式 中 //代表包含这个一个字符串 都是true
        console.log(sg.test('a'));
        console.log(sg.test('b')); //true
        console.log(sg.test('c')); //true
        console.log(sg.test('abcd')); //true
        console.log(sg.test('abcc')); //true
        console.log(sg.test('abbc')); //false
        console.log('----------------------');
        var rg = /^abc/; // 以 abc 开头 
        console.log(rg.test('abc')); //true
        console.log(rg.test('abcd')); //true
        console.log(rg.test('aabc')); //false
        console.log(rg.test('abbc')); //false
        console.log(rg.test('abcc')); //true

        console.log('--------第二行--------------');
        var agg = /abc$/; // 以 abc 结尾 
        console.log(agg.test('abc')); //true
        console.log(agg.test('abcd')); //false
        console.log(agg.test('aabc')); //true
        console.log(agg.test('abbc')); //false
        console.log(agg.test('abcc')); //false

        //精确匹配
        var right = /^abc$/ //必须输入abc
    </script>
</body>

</html>